import cn.tecnova.bean.AppmIndustryType
import com.alibaba.fastjson.{JSON, JSONArray}
import com.google.gson.Gson

/**
  * description:
  * Rabcheng
  * Date:2019/4/23 16:00
  **/
object TestGetJson {

  def main(args: Array[String]): Unit = {

    val ss = "{\n\"type\": \"company\",\n\"flag\": \"ins\",\n\"pkey\": [\"listString1\",\"listString2\"],\n\"data\":[{\"id\":\"ilehflhghs\",\"father_code\":\"5\",\"code\":\"666\",\"name\":\"不会编\",\"description\":\"也不会\"},{\"id\":\"shgisaaljgo\",\"father_code\":\"555\",\"code\":\"888\",\"name\":\"不会\",\"description\":\"还不会\"}],\n\"topic_name\": \"appm_industry_type\"\n}"

    val jSONObject = JSON.parseObject(ss)


    try {

      val array: JSONArray = jSONObject.getJSONArray("ata")


      println("///////")
      println(array)
      println("....")
      println(array.size())

      val nObject = array.getJSONObject(1)

      val code = nObject.getString("code")

      //    println(code)

      for (index <- 0 until array.size()) {

        val dataJson = array.getJSONObject(index)
        println(dataJson.toString)
        val name = dataJson.getString("code")

        println(name)

      }

      println(0 to 2)
      println(0 until 1)

      println("----------------------")


    }catch {
      case e:Exception =>println("数据异常")
    }


  }

}
